
<section id="content">

    <div class="page page-fullwidth-layout">

        <div class="pageheader">

            <div class="page-bar">

                <ul class="page-breadcrumb">
                    <li>
                        <a href="{:url('/admin')}"><i class="fa fa-home"></i> 起始页</a>
                    </li>
                    <li>
                        <a href="{:url('/admin/customers/index')}"><i class="fa fa-home"></i> 我的客户</a>
                    </li>
                    <li>
                        <a href="#">跟进记录</a>
                    </li>
                </ul>

            </div>
        </div>
        <!-- page content -->
        <div class="pagecontent">

            <!-- row -->
            <div class="row">
                <!-- col -->
                <div class="col-md-12">
                    <!-- tile -->
                    <section class="tile">
                        <!-- tile body -->
                        <div class="tile-body">
                            <div class="alert alert-info" style="display:none;">显示一些提示信息</div>

                            <div class="table-responsive">
                                <table class="table table-striped table-hover table-custom" id="products-list">
                                    <thead>
                                    <tr>
                                        <th>编号</th>
                                        <th>微信昵称</th>
                                        <th>客户电话</th>
                                        <th>跟进方式</th>
                                        <th>当前跟进时间</th>
                                        <th>下次跟进时间</th>
                                        <th>跟进内容</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    {foreach $followloglist as $item}
                                    <tr id="tr_{$item['follow_id']}">
                                        <td>{$item['follow_id']}</td>
                                        <td>{$item['c_nickname']}</td>
                                        <td>{$item['mobile']}</td>
                                        <td>
                                            {if condition="$item['follow_style'] eq 1"}
                                                电话
                                            {elseif condition="$item['follow_style'] eq 2"}
                                                短信
                                            {elseif condition="$item['follow_style'] eq 3"}
                                                QQ
                                            {elseif condition="$item['follow_style'] eq 4"}
                                                微信
                                            {elseif condition="$item['follow_style'] eq 5"}
                                                其他
                                            {/if}
                                        </td>
                                        <td>{$item['follow_time']|date='Y-m-d H:i',###}</td>
                                        <td>{$item['next_follow_time']|date='Y-m-d H:i',###}</td>
                                        <td>{$item['remark']}</td>
                                        <td>
                                            <a class="btn btn-info followdetail" followid="{$item['follow_id']}" href="javascript:void(0)">
                                                <i class="glyphicon glyphicon-edit icon-white"></i>
                                                详情
                                            </a>
                                            <a class="btn btn-danger" href="javascript:void(0);"  onclick="if(confirm('确定要删除该客户吗')){ deleteData({$item['follow_id']})}">
                                                <i class="glyphicon glyphicon-trash icon-white"></i>
                                                删除
                                            </a>
                                        </td>

                                    </tr>
                                    {/foreach}
                                    </tbody>
                                </table>
                            </div>
                            <div class="text-center">{$followloglist->render()}</div>
                        </div>
                        <!-- /tile body -->

                    </section>
                    <!-- /tile -->

                </div>
                <!-- /col -->
            </div>
            <!-- /row -->
        </div>
        <!-- /page content -->
        <script type="text/javascript">
            function deleteData(follow_id){
                $.ajax({
                    type:"get",
                    data: {'follow_id':follow_id},
                    url:"{:url($data.module_url.'delfollow')}",
                    success:function(data){
                        if(data.error == 0){
                            $('#tr_'+data.follow_id).remove();
                        }
                        $('.alert').html(data.msg).show();
                        setTimeout(function() {
                            $('.alert').hide();
                        }, 3000);
                    },
                    error:function(data){

                    }
                });
            }

            $('.followdetail').click(function(){
                var follow_id = $(this).attr('followid');
                $('#follow_id').val(follow_id);
                $.ajax({
                    type : "get",
                    url:"{:url($data.module_url.'followdetail')}",
                    data : {'follow_id':follow_id},
                    success: function(data){
                        $('#follow_style').val(data.follow_style);
                        $('#follow_time').val(data.follow_time);
                        $('#next_follow_time').val(data.next_follow_time);
                        $('#remark').val(data.remark);
                        $('#myModal').modal('show');
                    },
                    errror:function(data){
                        alert('服务器错误！');
                    }
                });
            })

            function checkform(){
                var follow_time = document.getElementById("follow_time").value;
                var remark = document.getElementById("remark").value;
                if(!follow_time){
                    alert("跟进时间不能为空");
                    return false;
                }
                if(!remark){
                    alert("备注不能为空");
                    return false;
                }
                document.getElementById("myform").submit();
            }

        </script>
    </div>
</section>
<!--/ CONTENT -->
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal"  tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">跟进详情</h4>
            </div>
            <div class="modal-body">
                <form id="myform" action="{:url($data.module_url).'updatefollowlog'}" method="post">
                    <input type="hidden" name="follow_id" id="follow_id" value="" />
                    <table>
                        <tr>
                            <td>
                                跟进方式：
                            </td>
                            <td>
                                <select class="form-control" name="follow_style" id="follow_style" style="width:100px">
                                    <option value="1">电话</option>
                                    <option value="2">短信</option>
                                    <option value="3">QQ</option>
                                    <option value="4">微信</option>
                                    <option value="5">其他</option>
                                </select>
                            </td>

                        </tr>
                        <tr>
                            <td>
                                此次跟进时间：
                            </td>
                            <td >
                                <input type="text" name="follow_time" id="follow_time" class="form-control" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',readOnly:true})"  style="width:150px" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                下次跟进时间：
                            </td>
                            <td>
                                <input type="text" name="next_follow_time" id="next_follow_time" class="form-control" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',readOnly:true})"  style="width:150px"/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                跟进备注：
                            </td>
                            <td>
                                <textarea id="remark" name="remark" class="form-control" rows="15" cols="15" style="width:300px"></textarea>
                            </td>
                        </tr>
                    </table>
                </form>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="checkform()">更新</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

